<?php
class opus extends CI_Model{
	function __construct(){
        parent::__construct();
        $this->load->database();
    }
    function get($params=array()){
    	$return=array();
    	if(isset($params['where'])){
    		$this->db->where($params['where']);
    	}
    	if(isset($params['select'])){
    		if(is_string($params['select'])){
    			$this->db->select($params['select']);
    		}
    	}
    	if(isset($params['like'])){
    		foreach($params['like'] as $key =>$value){
    			$this->db->like($key,$value);
    		}
    	}
    	if(isset($params['in'])){
    		foreach($params['in'] as $key => $value){
    			$this->db->where_in($key,$value);
    		}
    	}
    	if(isset($params['order'])){
    		foreach($params['order'] as $key => $value){
    			$this->db->order_by($key,$value);
    		}
    	}
    	if(isset($params['limit'])){
    		if(is_string($params['limit'])){
    			$this->db->limit($params['limit']);
    		}else if(is_array($params['limit'])){
    			$this->db->limit($params['limit'][1],$params['limit'][0]);
    		}
    	}
		$query=$this->db->get('opus');
    	$result=$query->result_array();
    	return $result;
    }
	function insert($params){
		$this->db->insert('opus',$params);
    	return $this->db->insert_id();
	}
	function delete($params=array()){
    	if(isset($params['where'])){
    		$this->db->where($params['where']);
    	}
		$this->db->delete('opus');
		return $this->db->affected_rows();
    }
	function update($params){
		if(isset($params['where'])){
    		$this->db->where($params['where']);
    	}
		$this->db->update('opus',$params['set']);
		return $this->db->affected_rows();
	}
}
?>